import React from "react";
// import ReactDOM from "react-dom";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App";

let container = null,
  root = null;

function render(props) {
  container = props.container;
  container = container
    ? container.querySelector("#root")
    : document.querySelector("#root");
  root = createRoot(container);
  root.render(<App />);
}


if (window.__POWERED_BY_QIANKUN__) {
  // eslint-disable-next-line no-undef
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
}

if (!window.__POWERED_BY_QIANKUN__) {
  render({});
}

export async function bootstrap() {
  console.log("react app bootstraped");
}

export async function mount(props) {
  console.log("react app mount", props);
  render(props);
}

export async function unmount(props) {
  console.log("react app unmount");
  root.unmount();
}
